package com.example.testanything;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;

public class Internet implements Runnable{
	private String url ;
	private int port ;
	Internet(String url ){
		this.url = url;
	}
	Internet (String url ,int port ){
		this.url = url;
		this.port =  port ;
	}
	@Override
	public void run() {
		// TODO Auto-generated method stub
	
		Socket client;
		SocketAddress remoteAddress = new InetSocketAddress("localhost",50000);	
		while (true){
			client = new Socket();
			try {
					
				
				client.connect(remoteAddress,30000);
				InputStream  IS = client.getInputStream();
				byte[] buf = new  byte[IS.available()];
				IS.read(buf);
				
			} catch (UnknownHostException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} finally {
				if (client != null){
					try {
						client.close();
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			
			}
			
			

		} //while end 

	} //run end
	
	
	
}
